package com.ihr360.job.core.repeat.policy;

import com.ihr360.job.core.repeat.RepeatContext;
import com.ihr360.job.core.repeat.RepeatStatus;

/**
 * Very simple {@link CompletionPolicy} that bases its decision on the result of
 * a batch operation. If the result is null or not continuable according to the
 * {@link RepeatStatus} the batch is complete, otherwise not.
 *
 * @author Dave Syer
 *
 */
public class DefaultResultCompletionPolicy extends CompletionPolicySupport {

    /**
     * True if the result is null, or a {@link RepeatStatus} indicating
     * completion.
     *
     * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext,
     *      RepeatStatus)
     */
    @Override
    public boolean isComplete(RepeatContext context, RepeatStatus result) {
        return (result == null || !result.isContinuable());
    }

    /**
     * Always false.
     *
     * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext)
     */
    @Override
    public boolean isComplete(RepeatContext context) {
        return false;
    }

}